<?php $this->start('admin_menu')?>
	<?php echo $this->element('admin_menu', array('str_item' => 'agents')) ?>
<?php $this->end(); ?>
<div class="agents view">
	<h1><?php echo __('Agent'); ?></h1>
	<?php echo $this->Session->flash(); ?>
	<table class='form-table'>
		<tr>
			<td class='left-cl-style'>Name</td>
			<td class='right-cl-style'><?php echo h($agent['Agent']['name']); ?></td>
		</tr>
		<tr>
			<td class='left-cl-style'>Address</td>
			<td class='right-cl-style'><?php echo h($agent['Agent']['address']); ?></td>
		</tr>
		<tr>
			<td class='left-cl-style'>Phone</td>
			<td class='right-cl-style'><?php echo h($agent['Agent']['phone']); ?></td>
		</tr>
		<tr>
			<td class='left-cl-style'>Email</td>
			<td class='right-cl-style'><?php echo h($agent['Agent']['email']); ?></td>
		</tr>
		<tr>
			<td class='left-cl-style'>Status</td>
			<td class='right-cl-style'><?php echo h($agent['Agent']['status']); ?></td>
		</tr>
		<tr>
			<td class='left-cl-style'>Type</td>
			<td class='right-cl-style'><?php echo h($agent['Agent']['type']); ?></td>
		</tr>
		<tr>
			<td class='left-cl-style'>Code</td>
			<td class='right-cl-style'><?php echo h($agent['Agent']['code']); ?></td>
		</tr>
		<tr>
			<td class='left-cl-style'>Account</td>
			<td class='right-cl-style'>
				<?php if(isset($agent['User']['email'])): ?>
					<?php echo $this->Html->link($agent['User']['email'], array('controller' => 'users', 'action' => 'view', $agent['User']['id'])); ?>
				<?php else: ?>
					<?php echo $this->Html->link('Create account', array('controller' => 'users', 'action' =>'add', '?' => array('aid' => $agent['Agent']['id'], 'email' => $agent['Agent']['email'])),
																	array('class' => 'action-link')); ?>
				<?php endif; ?>				
			</td>
		</tr>
		<tr>
			<td class='left-cl-style'>Credit</td>
			<td class='right-cl-style'>
			<?php if(isset($agent['Credit']['name'])): ?>
				<?php echo $this->Html->link($agent['Credit']['name'], array('controller' => 'credits', 'action' => 'view', $agent['Credit']['id'])); ?>
			<?php else: ?>
				<?php echo $this->Html->link('Add credit', array('controller' => 'credits', 'action' =>'add', '?' => array('aid' => $agent['Agent']['id'])),
															array('class' => 'action-link')); ?>			
			<?php endif; ?>				
			</td>
		</tr>
	</table>
</div>
<div class='actionct'>
	<span class='btn-act'>
			<span><?php echo $this->Html->link(__('List Agents'), array('action' => 'index'), array('class' => 'back-act')); ?></span>
	</span>
	<span class='btn-act'>
			<span>
				<?php echo $this->Form->postLink(__('Delete Agent'), array('action' => 'delete', $agent['Agent']['id']), array('class' => 'del-link'), __('Are you sure you want to delete # %s?', $agent['Agent']['id'])); ?>				 
			</span>
	</span>
	<span class='btn-act'>
			<span>
				<?php echo $this->Html->link(__('Edit Agent'), array('action' => 'edit', $agent['Agent']['id']), array('class' => 'edit-link')); ?> 
			</span>
	</span>
	<span class='btn-act'>
			<span>
				<?php echo $this->Html->link(__('New Agent'), array('action' => 'add')); ?>
			</span>
	</span>
</div>